package com.powernode.listener;

import com.alibaba.fastjson.JSON;
import com.powernode.domain.MsgModel;
import org.apache.rocketmq.common.message.MessageExt;
import org.apache.rocketmq.spring.annotation.ConsumeMode;
import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
import org.apache.rocketmq.spring.annotation.SelectorType;
import org.apache.rocketmq.spring.core.RocketMQListener;
import org.springframework.stereotype.Component;

/**
 * 监听带标签, 过滤的消息
 */
@Component
@RocketMQMessageListener(
        topic = "bootTagTopic",
        consumerGroup = "boot-tag-consumer-group",
        // selectorType = SelectorType.SQL92,   // SQL92过滤模式
        // selectorExpression = "a > 5"     // 条件: a in (3,5,7) 需要在broker.conf中开启enablePropertyFilter=true
        selectorType = SelectorType.TAG,    // tag过滤模式
        selectorExpression = "tagA || tagB"
)
public class CTagMsgListener implements RocketMQListener<MessageExt> {
    @Override
    public void onMessage(MessageExt message) {
        System.out.println(new String(message.getBody()));
    }
}
